Quickstart: Discrete Dynamic with the Python API ------------------------------------------------- This tutorial uses :std:ref:`Temperature forecasting in quickstart` provided with NeurEco installation. To work with the Discrete Dynamic NeurEco models in Python, import **NeurEcoDynamic** library: .. code-block:: python from NeurEco import NeurEcoDynamic as Dynamic Import numpy to handle the data sets: .. code-block:: python import numpy as np Load the data sets (see :std:ref:`Data preparation for NeurEco Discrete Dynamic python` and :std:ref:`Temperature forecasting in quickstart`): .. code-block:: python x_first_year = np.load("x_first_year.npy") t_first_year = x_first_year[:, 0:1] x_first_year = x_first_year[:, 1:] y_first_year = np.load("y_first_year.npy") y_first_year = y_first_year[:, 1:] x_year_2 = np.load("x_second_year.npy") t_year_2 = x_year_2[:, 0:1] x_year_2 = x_year_2[:, 1:] y_year_2 = np.load("y_second_year.npy") y_year_2 = y_year_2[:, 1:] To initialize a NeurEco object to handle the **Discrete Dynamic** problem: .. code-block:: python dynamic_model = Dynamic.DiscreteDynamic() To build the model, call method **build** with the parameters set for the problem under consideration (see :std:ref:`Build NeurEco Discrete Dynamic model with the Python API`). For this example, we will choose a validation percentage of 30%. Meaning that NeurEco will use the last 30% of the training trajectory as validation data. For example, if the training trajectory contains 1000 time steps, the first 700 steps will be used for training and the last 300 steps will be used for validation. .. code-block:: python dynamic_model.build(train_time_list=[t_first_year], train_exc_list=[x_first_year], train_out_list=[y_first_year], valid_percentage=30, # the rest of these parameters are optional write_model_to="./TemperatureForecasting/TemperatureForecasting.ernn", checkpoint_address="./TemperatureForecasting/TemperatureForecasting.checkpoint") .. note:: For detailed documentation on **build**, see :std:ref:`Build NeurEco Discrete Dynamic model with the Python API`. To evaluate the NeurEco Model on the testing data (the second year of data), call **evaluate** method: .. code-block:: python neureco_outputs_second_year = dynamic_model.evaluate([t_second_year], [x_second_year]) .. note:: For detailed documentation on **evaluate**, see :std:ref:`Evaluate NeurEco Discrete Dynamic model with the Python API`. To export the model as an FMU file: .. code-block:: python dynamic_model.export_fmu("./TemperatureForecasting/TemperatureForecasting.fmu") This export requires *embed* license. .. note:: For detailed documentation on **export**, see :std:ref:`Export NeurEco Discrete Dynamic model python` When the model is not needed any more, delete it from the memory: .. code-block:: python dynamic_model.delete() .. note:: For detailed documentation on Tabular Regression with the python API, see :std:ref:`Discrete Dynamic with the Python API`.